package day9;

public class 同步方法Demo4 {
    public static void main(String[] args) {
        final Shower s = new Shower();

        new Thread() {
            @Override
            public void run() {
                s.show();
            }
        }.start();

        new Thread() {
            @Override
            public void run() {
                s.show2();
            }
        }.start();

    }
}

class Shower{
    Object obj = new Object();

    public synchronized void show(){
        System.out.println("世");
        System.out.println("界");
        System.out.println("那");
        System.out.println("么");
        System.out.println("大");
    }

    public void show2(){
        synchronized (this){
            System.out.println("我");
            System.out.println("想");
            System.out.println("去");
            System.out.println("看");
            System.out.println("看");
        }
    }
}
